package ast;

import out.Out;
import mem.interfaces.IMem;
import environnement.interfaces.IEnv;
import exceptions.LogoException;
import ast.interfaces.IAST;
import ast.interfaces.IASTeq;

public class ASTeq implements IASTeq{
	private IAST op1;
	private IAST op2;

	public ASTeq(IAST op1,IAST op2){
		this.op1 = op1;
		this.op2 = op2;
	}

	@Override
	public Float eval(Out o, IEnv e, IMem m) throws LogoException{
		Float val1 = (Float) op1.eval(o, e, m);
		Float val2 = (Float) op2.eval(o, e, m);

		if (val1.compareTo(val2) == 0)
			return (float) 1;
		else 
			return (float) 0;
	}

	@Override
	public String toTreeString(String ident, IEnv e, IMem m) {
		return op1.toTreeString(ident, e, m) + "=" + op2.toTreeString(ident, e, m);
	}

	public IAST getOp1() {
		return op1;
	}

	public void setOp1(IAST op1) {
		this.op1 = op1;
	}

	public IAST getOp2() {
		return op2;
	}

	public void setOp2(IAST op2) {
		this.op2 = op2;
	}

}
